﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="../../WF/Portal/layui/css/layui.css" rel="stylesheet" />
    <script type="text/javascript" src="../../WF/Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../WF/Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../WF/Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../WF/Scripts/config.js" type="text/javascript"></script>
    <script src="../../WF/Comm/Gener.js" type="text/javascript"></script>
    <script src="../../WF/Portal/layui/layui.js" type="text/javascript"></script>
    <script src="../../WF/Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
    <script src="../../WF/Portal/js/vue/vue.js" type="text/javascript"></script>
    <script src="Toolbar.js"></script>
    <style>
        body {
            background: #fff
        }

        .Wkr-Share {
        }

            .Wkr-Share h5 {
                font-weight: bold;
                padding: 15px 0px 0px;
                color: #009688
            }

        .layui-form-switch {
            margin-top: 0px;
        }

        .pull-right {
            float: right;
            text-align: right
        }
    </style>
    <script type="text/javascript">
    </script>
</head>
<body>
    <div class="layui-fluid Wkr-Share" id="Wkr-Share" style="margin-top:15px">
        <div id="toolbar"> </div>
        <div class="layui-row">
            <div class="layui-col-sm6">
                <h5> 分享人员 </h5>
            </div>
            <div class="layui-col-sm6 pull-right">
                <form class="layui-form">
                    <div class="layui-form-item" style="margin-bottom:0px;">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" value="" id="TB_ShareTo" placeholder="请输入新增分享人员..." class="layui-input" style="padding:5px 10px; height:30px" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <input type="button" value="新增人员" @click="Add()" class="layui-btn layui-btn-sm layui-btn-danger" />
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody class="layui-form">
                <tr v-for="(item,index) in list">
                    <td>{{item.ShareToEmpName}}</td>
                    <td>
                        <div class="layui-form-item" style="padding:0px; margin:0px;">
                            <input v-if="item.ShareState ==1" checked="" type="checkbox" :value="item.ShareState" name="TB_ShareState" :id="item.MyPK" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
                            <input v-if="item.ShareState == 0" type="checkbox" :value="item.ShareState" name="TB_ShareState" :id="item.MyPK" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
                        </div>
                    </td>
                    <td width="110"><span class="layui-btn layui-btn-xs  layui-btn-warm" @click="Del(item.MyPK)" :data-mypk="item.MyPK">删除</span></td>
                </tr>
            </tbody>
        </table>
        <!--<h5> 可能要分享的人 </h5>

        <table class="layui-table">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>部门</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>xxxx</td>
                    <td>xxx</td>
                    <td>加入</td>
                </tr>

                <tr>
                    <td>xxxx</td>
                    <td>xxx</td>
                    <td>加入</td>
                </tr>

                <tr>
                    <td>xxxx</td>
                    <td>xxx</td>
                    <td>加入</td>
                </tr>

                <tr>
                    <td>xxxx</td>
                    <td>xxx</td>
                    <td>加入</td>
                </tr>
            </tbody>
        </table>-->

    </div>

    <script>
        new Vue({
            el: '#Wkr-Share',
            data: {
                list: [],

            },
            methods: {
                Add: function () {
                    var webUser = new WebUser();
                    var en = new Entity("BP.CCOA.WorkLog.WorkShare");
                    en.EmpNo = webUser.No;
                    en.EmpName = webUser.EmpName;
                    en.ShareToEmpNo = $("#TB_ShareTo").val();
                    try {

                        en.Insert();
                        layer.msg('添加成功')
                        Reload();
                    } catch (e) {
                        layer.msg('分享错误，该账号不存在或者账号输入错误.')

                    }
                },
                Del: function (mypk) {
                    if (window.confirm("确定要删除吗?") == false)
                        return;
                    var endel = new Entity("BP.CCOA.WorkLog.WorkShare", mypk);
                    var data = endel.Delete();
                    Reload();
                }

            },
            mounted: function () {
                var ens = new Entities("BP.CCOA.WorkLog.WorkShares");
                ens.Retrieve();
                ens = ens.TurnToArry();
                console.log(ens);
                this.list = ens
                /*var data = ens.DoMethodReturnJSON("Default_Init");*/
                //console.log(data);
            }

        })
        layui.use('table', function () {
            var table = layui.table
                , form = layui.form;
            form.on('switch(switchTest)', function (obj) {

                var mypk = this.id;
                var enst = new Entity("BP.CCOA.WorkLog.WorkShare", mypk);
                if (obj.elem.checked == true) {
                    enst.ShareState = 1;
                } else {
                    enst.ShareState = 0;
                }
                enst.Update();

                // table.reload()
                //layer.tips(this.value + ' ' + this.id + '：' + obj.elem.checked, obj.othis);
            });
        });
    </script>

</body>
</html>